class Member < ActiveRecord::Base
  has_many :characters
  belongs_to :member_status
  validates_presence_of :name
  
  def mission_registrations
    regs = []
    characters.each { |c| regs.push c.mission_registrations }
    return regs
  end
  
  def leads_mission?(mission)
    if mission.member.nil?
      return false
    end
    return mission.member == self
  end
  
  def is_admin?
    if can_edit_permissions == 1 or can_edit_any_member == 1
      return true
    end
    return false
  end
  
  def smf_member
    SMFMember.find_by_memberName(@name)
  end
    
  def rank
    return SMFMembergroups.find_by_ID_GROUP(smf_member.ID_GROUP).groupName
  end
end